*********************************************************************************
****** This do file replicates tables and figures in "Is Democracy Pro-poor? An 
****** Empirical Test of Sen Hypothesis with Worldwide Evidence" submitted to 
****** Governance
*********************************************************************************

use Dem&pov_repli.dta,clear

duplicates list wb_code year
duplicates drop wb_code year, force /***Drop duplicates by country code and year***/
xtset wb_code year

***** Figure 1. Trends of Global Poverty and Democracy
 
by year, sort: egen tmean_pov19=mean(pov_pop_19)
lab var tmean_pov19 "Poverty headcount ratio"

by year, sort: egen mean_bmr_dem=mean(bmr_dem*100)
lab var mean_bmr_dem "Share of democratic countries (%)"

by year, sort: egen mean_polity2=mean(polity2)
by year, sort: egen mean_fh_ipolity=mean(fh_ipolity)

by year, sort: egen tmean_povg19=mean(pov_gap_19)
lab var tmean_povg19 "Poverty gap"

tsline tmean_pov19 if wb_code==1&year>1994, yaxis(1)  || /// 
       tsline tmean_povg19 if wb_code==1&year>1994, yaxis(1) || ///
	   tsline mean_bmr_dem if wb_code==1&year>1994, /// 
	   yaxis(2) ytitle(Average poverty at $1.9 a day (%))   /***Figure 1***/

***** Figure 2. Poverty by Regime Type
 
by wb_code, sort: egen sum_bmr_dem=sum(bmr_dem)

gen d_all_dem=1 if sum_bmr_dem>25
replace d_all_dem=0 if d_all_dem==.
lab var d_all_dem "Democracy throughout 1990-2015"

gen d_all_aut=1 if sum_bmr_dem==0
replace d_all_aut=0 if d_all_aut==.
lab var d_all_aut "Autocracy throughout 1990-2015"
		  					  	
gen dem_rev=1 if cname=="Central African Republic"|cname=="Guinea-Bissau"| /// 
        cname=="Sri Lanka"|cname=="Madagascar"|cname=="Mali"|cname=="Mozambique"| /// 
		cname=="Russia"|cname=="Venezuela"|cname=="Belarus"|cname=="Gambia"
replace dem_rev=0 if dem_rev==.&bmr_dem!=.
lab var dem_rev "Democracy reversed countries"

gen dem_suc=1 if cname=="Antigua and Barbuda"|cname=="Brundi"| /// 
        cname=="Comoros"|cname=="Fiji"|cname=="Geogia"|cname=="Gahana"| /// 
		cname=="Croatia"|cname=="Indonesia"|cname=="Kenya"| /// 
        cname=="Liberia"|cname=="Lesotho"|cname=="Mexico"|cname=="Nigeria"| /// 
		cname=="Peru"|cname=="Sierra Leone"|cname=="Tunisia"| /// 
        cname=="Zambia"|cname=="Kiribati"|cname=="Andorra"|cname=="Benin"| /// 
		cname=="Bosnia and Herzegovina"|cname=="Caoe Verde"| ///
		cname=="Czech Republic"|cname=="Estonia"|cname=="Guyana"| /// 
		cname=="Liechtenstein"|cname=="Lithuania"|cname=="Latvia"| /// 
		cname=="Nigeria"|cname=="Monaco"|cname=="Moldova"| /// 
		cname=="Marshall Islands"|cname=="Macedonia"|cname=="Malawi"| /// 
		cname=="Micronesia"|cname=="Panama"|cname=="Palau"| /// 
		cname=="Sao Tome and Principe"|cname=="Suriname"|cname=="Slovakia"| /// 
        cname=="Slovenia"|cname=="Ukraine"|cname=="South Africa"
replace dem_suc=0 if dem_suc==.&bmr_dem!=.
lab var dem_suc "Democratization countries"

gen dem_int=1 if cname=="Albania"|cname=="Bangladesh"| /// 
        cname=="Ecuador"|cname=="Honduras"|cname=="Maldives"|cname=="Niger"| ///
		cname=="Nepal"|cname=="Pakistan(1971-)"|cname=="Solomon Islands"| /// 
		cname=="Thailand"
replace dem_int=0 if dem_int==.&bmr_dem!=.
lab var dem_int "Democracy interupted countries"

xtset wb_code year

gen dem_typ3=1 if d_all_dem==1
replace dem_typ3=4 if d_all_aut==1
replace dem_typ3=2 if dem_suc==1|dem_int==1
replace dem_typ3=3 if dem_rev==1

tab dem_typ3
lab var dem_typ3 "All-the-time democracy, Democratized countries, Democracy reversed, All-the-time autocracy" 
label values dem_typ3 typelbl7
label define typelbl7 1"All-the-time democracy" 2"Democratized countries" 3"Democracy reversed" 4"All-the-time autocracy" 

lgraph pov_pop_19 year if year>1994, fit(fpfit) by(dem_typ3) ///
                           ytitle(Poverty headcount ratio at $1.9 a day (%)) /// 
						   lopt(msize(Medium-small)) colorg(on)  /***Fig. 2(1)***/
graph save Fig_21.gph
						   
lgraph pov_gap_19 year if year>1994, fit(fpfit) by(dem_typ3) ///
                           ytitle(Poverty gap at $1.9 a day (%)) /// 
						   lopt(msize(Medium-small)) colorg(on) /***Fig. 2(2)***/	
graph save Fig_22.gph
graph combine Fig_21.gph Fig_22.gph, col(1)	  /****Figure 2, manually edited***/				   

***** Table A2. Summary statistics

sum pov_pop_19 pov_gap_19 pov_pop_32 pov_gap_32 pov_hc_55 pov55 bmr_dem polity2 ///
    fh_ipolity lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl hf_efiscore p_durable ///
	wbgi_cce wbgi_gee wbgi_pse if year>1994   /***Table A2***/
                                                               
corr pov_pop_19 pov_gap_19 pov_pop_32 pov_gap_32 pov_hc_55 pov55 bmr_dem polity2 ///
     fh_ipolity lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl hf_efiscore p_durable ///
	 wbgi_cce wbgi_gee wbgi_pse if year>1994
		
***** Table 1. Democracy and extreme poverty

xtset wb_code year

xtreg pov_pop_19 bmr_dem i.year if year>1994, fe robust
est store fe11

xtreg pov_gap_19 bmr_dem i.year if year>1994, fe robust
est store fe12

xtreg pov_pop_19 bmr_dem lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl i.year ///
                 if year>1994, fe robust
est store fe21

xtreg pov_gap_19 bmr_dem lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl i.year ///
                 if year>1994, fe robust
est store fe22

xtreg pov_pop_19 bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 p_durable i.year if year>1994, fe robust
est store fe31 

xtreg pov_gap_19 bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 p_durable i.year if year>1994, fe robust
est store fe32

xtreg pov_pop_19 bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable i.year if year>1994, fe robust
est store fe31 

xtreg pov_gap_19 bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable i.year if year>1994, fe robust
est store fe32

xtreg pov_pop_19 bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable wbgi_cce wbgi_gee wbgi_pse i.year ///
				 if year>1994, fe robust
est store fe41 

xtreg pov_gap_19  bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable wbgi_cce wbgi_gee wbgi_pse i.year /// 
				 if year>1994, fe robust
est store fe42 
  
outreg2 [fe11 fe12 fe21 fe22 fe31 fe32 fe41 fe42] using result, dec(3) word see ///
      keep(bmr_dem lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl hf_efiscore /// 
	  p_durable wbgi_cce wbgi_gee wbgi_pse) replace  
	                              /***Table 2. Democracy and extreme poverty ***/
	
***** Table 2. Democracy and other poverty measures

xtreg pov_pop_32 bmr_dem i.year if year>1994, fe robust
est store fe11

xtreg pov_pop_32 bmr_dem lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl hf_efiscore /// 
                 p_durable wbgi_cce wbgi_gee wbgi_pse i.year if year>1994, fe robust
est store fe12

xtreg pov_gap_32 bmr_dem i.year if year>1994, fe robust
est store fe21

xtreg pov_gap_32 bmr_dem lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl hf_efiscore /// 
                 p_durable i.year if year>1994, fe robust
est store fe22  

xtreg pov_hc_55 bmr_dem i.year if year>1994, fe robust
est store fe31

xtreg pov_hc_55 bmr_dem lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl hf_efiscore ///
                p_durable i.year if year>1994, fe robust
est store fe32

xtreg pov55 bmr_dem i.year if year>1994, fe robust
est store fe41

xtreg pov55 bmr_dem lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl hf_efiscore ///
                p_durable wbgi_cce wbgi_gee wbgi_pse i.year if year>1994, fe robust
est store fe42

outreg2 [fe11 fe12 fe21 fe22  fe31 fe32 fe41 fe42] using result, dec(3) word ///
see replace keep(bmr_dem) nocons   /****Table 2. Other poverty measures***/

***** Table A5. Parallel trends test

**** Generate leads and lags of binary democracy

gen f1_bmr_dem=f1.bmr_dem
gen bmr_dem_f1=f1_bmr_dem-bmr_dem
replace bmr_dem_f1=0 if bmr_dem_f1==-1

replace bmr_dem_f1=0 if (cname=="Albania"&year==1996)|(cname=="Bangladesh"&year==2008)| /// 
                        (cname=="Niger"&year==1998)|(cname=="Niger"&year==2010)| /// 
						(cname=="Nepal"&year==2007)|(cname=="Thailand"&year==2010)

by wb_code, sort:egen no_dem=sum(bmr_dem_f1)						
drop no_dem	

gen f2_bmr_dem=f2.bmr_dem
br wb_code year f2_bmr_dem bmr_dem

gen bmr_dem_f2=f2_bmr_dem-f1_bmr_dem
replace bmr_dem_f2=0 if bmr_dem_f2==-1

by wb_code, sort:egen no_dem=sum(bmr_dem_f2)
replace bmr_dem_f2=0 if (cname=="Albania"&year==1995)|(cname=="Bangladesh"&year==2007)| /// 
                        (cname=="Niger"&year==1997)|(cname=="Niger"&year==2009)| /// 
						(cname=="Nepal"&year==2006)|(cname=="Thailand"&year==2009)
drop no_dem

by wb_code, sort:egen no_dem=sum(bmr_dem_f2)						
drop no_dem						

gen f3_bmr_dem=f3.bmr_dem
gen bmr_dem_f3=f3_bmr_dem-f2_bmr_dem
replace bmr_dem_f3=0 if bmr_dem_f3==-1

by wb_code, sort: egen no_dem=sum(bmr_dem_f3)
replace bmr_dem_f3=0 if (cname=="Albania"&year==1994)|(cname=="Bangladesh"&year==2006)| /// 
                        (cname=="Niger"&year==1996)|(cname=="Niger"&year==2008)| /// 
						(cname=="Nepal"&year==2005)|(cname=="Thailand"&year==2008)
drop no_dem

by wb_code, sort:egen no_dem=sum(bmr_dem_f3)						
drop no_dem	

gen f4_bmr_dem=f4.bmr_dem
gen bmr_dem_f4=f4_bmr_dem-f3_bmr_dem
replace bmr_dem_f4=0 if bmr_dem_f4==-1

by wb_code, sort:egen no_dem=sum(bmr_dem_f4)
replace bmr_dem_f4=0 if (cname=="Albania"&year==1993)|(cname=="Bangladesh"&year==2005)| /// 
                        (cname=="Niger"&year==1995)|(cname=="Niger"&year==2007)| /// 
						(cname=="Nepal"&year==2004)|(cname=="Thailand"&year==2007)
drop no_dem

by wb_code, sort:egen no_dem=sum(bmr_dem_f4)					
drop no_dem	

gen f5_bmr_dem=f5.bmr_dem
gen bmr_dem_f5=f5_bmr_dem-f4_bmr_dem
replace bmr_dem_f5=0 if bmr_dem_f5==-1

by wb_code, sort:egen no_dem=sum(bmr_dem_f5)
replace bmr_dem_f5=0 if (cname=="Albania"&year==1992)|(cname=="Bangladesh"&year==2004)| /// 
                        (cname=="Niger"&year==1994)|(cname=="Niger"&year==2006)| /// 
						(cname=="Nepal"&year==2003)|(cname=="Thailand"&year==2006)
drop no_dem

by wb_code, sort:egen no_dem=sum(bmr_dem_f1)						
drop no_dem	

gen f6_bmr_dem=f6.bmr_dem
gen bmr_dem_f6=f6_bmr_dem-f5_bmr_dem
replace bmr_dem_f6=0 if bmr_dem_f6==-1

gen bmr_dem_l0=bmr_dem-l.bmr_dem
replace bmr_dem_l0=0 if bmr_dem_l0<0

by wb_code, sort:egen no_dem=sum(bmr_dem_l0)
replace bmr_dem_l0=0 if (cname=="Albania"&year==1997)|(cname=="Bangladesh"&year==2009)| /// 
                        (cname=="Niger"&year==1999)|(cname=="Niger"&year==2011)| /// 
						(cname=="Nepal"&year==2008)|(cname=="Thailand"&year==2011)
drop no_dem

**** Conduct parallel trends test

xtreg pov_pop_19  bmr_dem_f4 bmr_dem_f3 bmr_dem_f2 bmr_dem_f1 bmr_dem ///
                  lwb_gdppc11  hc lpop_dnst wdi_trade /// 
				  imf_infl hf_efiscore  p_durable wbgi_cce wbgi_gee wbgi_pse i.year ///
				  if year>1994, fe robust
est store fe1

xtreg pov_gap_19  bmr_dem_f4 bmr_dem_f3 bmr_dem_f2 bmr_dem_f1 bmr_dem ///
                  lwb_gdppc11  hc lpop_dnst wdi_trade /// 
				  imf_infl hf_efiscore  p_durable wbgi_cce wbgi_gee wbgi_pse i.year ///
				  if year>1994, fe robust
est store fe2


xtreg pov_pop_32  bmr_dem_f4 bmr_dem_f3 bmr_dem_f2 bmr_dem_f1 bmr_dem ///
                  lwb_gdppc11  hc lpop_dnst wdi_trade /// 
				  imf_infl hf_efiscore  p_durable wbgi_cce wbgi_gee wbgi_pse i.year ///
				  if year>1994, fe robust
est store fe3

xtreg pov_gap_32  bmr_dem_f4 bmr_dem_f3 bmr_dem_f2 bmr_dem_f1 bmr_dem ///
                  lwb_gdppc11  hc lpop_dnst wdi_trade /// 
				  imf_infl hf_efiscore  p_durable wbgi_cce wbgi_gee wbgi_pse i.year /// 
				  if year>1994, fe robust
est store fe4

xtreg pov_hc_55  bmr_dem_f4 bmr_dem_f3 bmr_dem_f2 bmr_dem_f1 bmr_dem ///
                 lwb_gdppc11  hc lpop_dnst wdi_trade /// 
				 imf_infl hf_efiscore  p_durable wbgi_cce wbgi_gee wbgi_pse i.year ///
				 if year>1994, fe robust
est store fe5

xtreg pov55  bmr_dem_f4 bmr_dem_f3 bmr_dem_f2 bmr_dem_f1 bmr_dem ///
                lwb_gdppc11  hc lpop_dnst wdi_trade /// 
				imf_infl hf_efiscore  p_durable wbgi_cce wbgi_gee wbgi_pse i.year ///
			    if year>1994, fe robust
est store fe6


outreg2 [fe1 fe2 fe3 fe4 fe5 fe6 ] using result, dec(3) word replace see ///
                 keep(bmr*)  nocons  /****Table A5****/

**** Table A6. Results Removing contaminated obs. that is, close to democratiztion

gen bmr_dem_l1=l1.bmr_dem-l2.bmr_dem
sum bmr_dem_l1
replace bmr_dem_l1=0 if bmr_dem_l1<0

by wb_code, sort:egen no_dem=sum(bmr_dem_l1)
replace bmr_dem_l1=0 if (cname=="Albania"&year==1998)|(cname=="Bangladesh"&year==2010)| /// 
                        (cname=="Niger"&year==2000)|(cname=="Niger"&year==2012)| /// 
						(cname=="Nepal"&year==2009)|(cname=="Thailand"&year==2012)
drop no_dem

xtreg pov_pop_19  bmr_dem  ///
                  lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl hf_efiscore ///
                  p_durable wbgi_cce wbgi_gee wbgi_pse i.year /// 
				  if year>1994&bmr_dem_f2!=1&bmr_dem_f1!=1&bmr_dem_l0!=1, fe robust
est store fe01

xtreg pov_gap_19  bmr_dem  ///
                  lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl hf_efiscore ///
                  p_durable wbgi_cce wbgi_gee wbgi_pse i.year /// 
				  if year>1994&bmr_dem_f2!=1&bmr_dem_f1!=1&bmr_dem_l0!=1, fe robust
est store fe02
 
xtreg pov_pop_32  bmr_dem  ///
                  lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl hf_efiscore ///
                  p_durable wbgi_cce wbgi_gee wbgi_pse i.year /// 
				  if year>1994&bmr_dem_f2!=1&bmr_dem_f1!=1&bmr_dem_l0!=1, fe robust
est store fe11


xtreg pov_gap_32  bmr_dem  ///
                  lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl hf_efiscore ///
                  p_durable wbgi_cce wbgi_gee wbgi_pse i.year ///
				  if year>1994&bmr_dem_f2!=1&bmr_dem_f1!=1&bmr_dem_l0!=1, fe robust
est store fe12


xtreg pov_hc_55  bmr_dem  ///
                 lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl hf_efiscore ///
                 p_durable wbgi_cce wbgi_gee wbgi_pse i.year /// 
				 if year>1994&bmr_dem_f2!=1&bmr_dem_f1!=1&bmr_dem_l0!=1, fe robust
est store fe21


xtreg pov55  bmr_dem  ///
             lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl hf_efiscore ///
             p_durable wbgi_cce wbgi_gee wbgi_pse i.year ///
		     if year>1994&bmr_dem_f2!=1&bmr_dem_f1!=1&bmr_dem_l0!=1, fe robust
est store fe22


outreg2 [fe0* fe11 fe12 fe21 fe22] using result, dec(3) word see replace /// 
                 keep(bmr_dem) nocons   /****Table A6****/

***** Table A7. Alternative democracy index


xtreg pov_pop_19 polity2 lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl /// 
                 hf_efiscore p_durable wbgi_cce wbgi_gee wbgi_pse i.year /// 
				 if year>1994, fe robust
est store fe11  

xtreg pov_pop_19 fh_ipolity2 lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl /// 
                 hf_efiscore  p_durable wbgi_cce wbgi_gee wbgi_pse i.year /// 
				 if year>1994, fe robust
est store fe12

xtreg pov_gap_19 polity2 lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl /// 
                 hf_efiscore p_durable wbgi_cce wbgi_gee wbgi_pse i.year /// 
				 if year>1994, fe robust
est store fe13  

xtreg pov_gap_19 fh_ipolity2 lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl /// 
                 hf_efiscore  p_durable wbgi_cce wbgi_gee wbgi_pse i.year /// 
				 if year>1994, fe robust
est store fe14

xtreg pov_pop_32 polity2 lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl /// 
                 hf_efiscore p_durable wbgi_cce wbgi_gee wbgi_pse i.year /// 
				 if year>1994, fe robust
est store fe21  

xtreg pov_pop_32 fh_ipolity2 lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl /// 
                 hf_efiscore  p_durable wbgi_cce wbgi_gee wbgi_pse i.year /// 
				 if year>1994, fe robust
est store fe22

xtreg pov_gap_32 polity2 lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl /// 
                 hf_efiscore p_durable wbgi_cce wbgi_gee wbgi_pse i.year /// 
				 if year>1994, fe robust
est store fe23  

xtreg pov_gap_32 fh_ipolity2 lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl /// 
                 hf_efiscore  p_durable wbgi_cce wbgi_gee wbgi_pse i.year ///
				 if year>1994, fe robust
est store fe24

xtreg pov_hc_55 polity2 lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl /// 
                 hf_efiscore p_durable wbgi_cce wbgi_gee wbgi_pse i.year /// 
				 if year>1994, fe robust
est store fe31  

xtreg pov_hc_55 fh_ipolity2 lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl /// 
                 hf_efiscore  p_durable wbgi_cce wbgi_gee wbgi_pse i.year ///
				 if year>1994, fe robust
est store fe32

xtreg pov55 polity2 lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl /// 
                 hf_efiscore p_durable wbgi_cce wbgi_gee wbgi_pse i.year /// 
				 if year>1994, fe robust
est store fe33  

xtreg pov55 fh_ipolity2 lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl /// 
                 hf_efiscore  p_durable wbgi_cce wbgi_gee wbgi_pse i.year ///
				 if year>1994, fe robust
est store fe34


outreg2 [fe11 fe12 fe13 fe14 fe21 fe22 fe23 fe24 fe31 fe32 fe33 fe34] using result, dec(3) word see replace ///
                 keep(polity2 fh_ipolity2) nocons 
				                   /****Table A7****/
**** Table A8. Results with Propensity-Score Matching method
g att = .
gen m_dem=.
gen wt=.
qui forvalues num = 1995/2014 {
      psmatch2 bmr_dem lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable if year == `num',  out(pov_pop_19) norepl
	  replace att = r(att) if year == `num' 
	  replace m_dem = _treat if year==	`num'
	  replace wt = _weight if year == `num'
	  }
	  sum att
	  sum m_dem
	  	  
xtreg pov_pop_19 bmr_dem lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore p_durable wbgi_cce wbgi_gee wbgi_pse i.year [fweight=wt] ///
				 if year>1994, fe robust
est store psm11
				 
qui forvalues num = 1995/2014 {
      psmatch2 bmr_dem lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable if year == `num',  out(pov_gap_19) norepl
	  replace att = r(att) if year == `num' 
	  replace m_dem = _treat if year==	`num'
	  replace wt = _weight if year == `num'
	  }
	  sum att
	  sum m_dem
	  	  
xtreg pov_gap_19 bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore p_durable wbgi_cce wbgi_gee wbgi_pse i.year [fweight=wt] ///
				 if year>1994, fe robust
est store psm12				 
				 
qui forvalues num = 1995/2014 {
      psmatch2 bmr_dem lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore p_durable if year == `num',  out(pov_pop_32) norepl
	  replace att = r(att) if year == `num' 
	  replace m_dem = _treat if year==	`num'
	  replace wt = _weight if year == `num'
	  }
	  sum att
	  sum m_dem
	  	  
xtreg pov_pop_32 bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore p_durable wbgi_cce wbgi_gee wbgi_pse i.year [fweight=wt] ///
				 if year>1994, fe robust
est store psm21

qui forvalues num = 1995/2014 {
      psmatch2 bmr_dem lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable if year == `num',  out(pov_gap_32) norepl
	  replace att = r(att) if year == `num' 
	  replace m_dem = _treat if year==	`num'
	  replace wt = _weight if year == `num'
	  }
	  sum att
	  sum m_dem
	  	  
xtreg pov_gap_32 bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore p_durable wbgi_cce wbgi_gee wbgi_pse i.year [fweight=wt] ///
				 if year>1994, fe robust
est store psm22	

qui forvalues num = 1995/2014 {
      psmatch2 bmr_dem lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable if year == `num',  out(pov_hc_55) norepl
	  replace att = r(att) if year == `num' 
	  replace m_dem = _treat if year==	`num'
	  replace wt = _weight if year == `num'
	  }
	  sum att
	  sum m_dem
	    
xtreg pov_hc_55 bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore p_durable wbgi_cce wbgi_gee wbgi_pse i.year [fweight=wt] ///
				 if year>1994, fe robust
est store psm31	

qui forvalues num = 1995/2014 {
      psmatch2 bmr_dem lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable if year == `num',  out(pov55) norepl
	  replace att = r(att) if year == `num' 
	  replace m_dem = _treat if year==	`num'
	  replace wt = _weight if year == `num'
	  }
	  sum att
	  sum m_dem
	  	  
xtreg pov55 bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore p_durable wbgi_cce wbgi_gee wbgi_pse i.year [fweight=wt] ///
				 if year>1994, fe robust
est store psm32

outreg2 [psm11 psm12 psm21 psm22 psm31 psm32] using rob_psm, word dec(3) /// 
                     keep(bmr_dem) see replace                /*** Table A8****/
				   
***** Table A9. A formal DID framework

xtset wb_code year

xtreg pov_pop_19 bmr_dem lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl  hf_efiscore ///
                 p_durable wbgi_cce wbgi_gee wbgi_pse i.year if /// 
				 d_all_dem==0&year>1994, fe robust
est store fe11 

xtreg pov_gap_19 bmr_dem lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl  hf_efiscore ///
                 p_durable wbgi_cce wbgi_gee wbgi_pse i.year if /// 
				 d_all_dem==0&year>1994, fe robust
est store fe12 
 
xtreg pov_pop_32 bmr_dem lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl  hf_efiscore ///
                 p_durable wbgi_cce wbgi_gee wbgi_pse i.year if /// 
				 d_all_dem==0&year>1994, fe robust
est store fe21 

xtreg pov_gap_32 bmr_dem lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl  hf_efiscore ///
                 p_durable wbgi_cce wbgi_gee wbgi_pse i.year if /// 
				 d_all_dem==0&year>1994, fe robust
est store fe22

xtreg pov_hc_55 bmr_dem lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl  hf_efiscore ///
                 p_durable wbgi_cce wbgi_gee wbgi_pse i.year if ///
				 d_all_dem==0&year>1994, fe robust
est store fe31 

xtreg pov55 bmr_dem lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl  hf_efiscore ///
                 p_durable wbgi_cce wbgi_gee wbgi_pse i.year if /// 
				 d_all_dem==0&year>1994, fe robust
est store fe32

outreg2 [fe11 fe12 fe21 fe22 fe31 fe32] using result, dec(3) word see replace ///
                 keep(bmr_dem) nocons   /****Table A9 Panel A****/
				 
xtreg pov_pop_19 bmr_dem lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl  hf_efiscore ///
                 p_durable wbgi_cce wbgi_gee wbgi_pse i.year if ///
				 d_all_aut==0&year>1994, fe robust
est store fe11 

xtreg pov_gap_19 bmr_dem lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl  hf_efiscore ///
                 p_durable wbgi_cce wbgi_gee wbgi_pse i.year if /// 
				 d_all_aut==0&year>1994, fe robust
est store fe12 
 
xtreg pov_pop_32 bmr_dem lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl  hf_efiscore ///
                 p_durable wbgi_cce wbgi_gee wbgi_pse i.year if /// 
				 d_all_aut==0&year>1994, fe robust
est store fe21 

xtreg pov_gap_32 bmr_dem lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl  hf_efiscore ///
                 p_durable wbgi_cce wbgi_gee wbgi_pse i.year if /// 
				 d_all_aut==0&year>1994, fe robust
est store fe22

xtreg pov_hc_55 bmr_dem lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl  hf_efiscore ///
                 p_durable wbgi_cce wbgi_gee wbgi_pse i.year if /// 
				 d_all_aut==0&year>1994, fe robust
est store fe31 

xtreg pov55 bmr_dem lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl  hf_efiscore ///
                 p_durable wbgi_cce wbgi_gee wbgi_pse i.year if /// 
				 d_all_aut==0&year>1994, fe robust
est store fe32

outreg2 [fe11 fe12 fe21 fe22 fe31 fe32] using result, dec(3) word see replace ///
                 keep(bmr_dem) nocons   /****Table A9 Panel B****/				 

					 				 
**** Table A10. Results from the interpolation of missing values in poverty measures
xtset wb_code year

gen yr_aft_95=1 if year>1994
replace yr_aft_95=0 if yr_aft_95==.
						 
gen one=1 if pov_pop_19!=.
replace one=0 if one==.

by wb_code yr_aft_95, sort: egen sone=sum(one)
gen xpov_pop_19=pov_pop_19 
by wb_code, sort: replace xpov_pop_19=(xpov_pop_19[_n-1]+xpov_pop_19[_n+1])/2 ///
                 if xpov_pop_19[_n-1]!=.&xpov_pop_19[_n+1]!=.&xpov_pop_19[_n]==.
br wb_code year xpov_pop_19 pov_pop_19
by wb_code, sort: replace xpov_pop_19=xpov_pop_19[_n-1] if xpov_pop_19[_n-1]!=. /// 
                            &xpov_pop_19[_n]==.&sone>5

drop one sone							
gen one=1 if pov_gap_19!=.
replace one=0 if one==.
by wb_code yr_aft_95, sort: egen sone=sum(one)							
gen xpov_gap_19=pov_gap_19 
by wb_code, sort: replace xpov_gap_19=(xpov_gap_19[_n-1]+xpov_gap_19[_n+1])/2 ///
                 if xpov_gap_19[_n-1]!=.&xpov_gap_19[_n+1]!=.&xpov_gap_19[_n]==.
br wb_code year xpov_gap_19 pov_gap_19
by wb_code, sort: replace xpov_gap_19=xpov_gap_19[_n-1] if xpov_gap_19[_n-1]!=. /// 
                            &xpov_gap_19[_n]==.&sone>5

drop one sone
gen one=1 if pov_pop_32!=.
replace one=0 if one==.
by wb_code yr_aft_95, sort: egen sone=sum(one)
gen xpov_pop_32=pov_pop_32 
by wb_code, sort: replace xpov_pop_32=(xpov_pop_32[_n-1]+xpov_pop_32[_n+1])/2 /// 
                 if xpov_pop_32[_n-1]!=.&xpov_pop_32[_n+1]!=.&xpov_pop_32[_n]==.
br wb_code year xpov_pop_32 pov_pop_32
by wb_code, sort: replace xpov_pop_32 = xpov_pop_32[_n-1] if xpov_pop_32[_n-1]!= . /// 
                            & xpov_pop_32[_n] == . & sone>5
														
drop one sone							
gen one=1 if pov_gap_32!=.
replace one=0 if one==.
by wb_code yr_aft_95, sort: egen sone=sum(one)							
gen xpov_gap_32=pov_gap_32 
by wb_code, sort: replace xpov_gap_32=(xpov_gap_32[_n-1]+xpov_gap_32[_n+1])/2 /// 
                  if xpov_gap_32[_n-1]!=.&xpov_gap_32[_n+1]!=.&xpov_gap_32[_n]==.
br wb_code year xpov_gap_32 pov_gap_32
by wb_code, sort: replace xpov_gap_32 = xpov_gap_32[_n-1] if xpov_gap_32[_n-1]!= . /// 
                            & xpov_gap_32[_n] == . & sone>5							

drop one sone
gen one=1 if pov_hc_55!=.
replace one=0 if one==.
by wb_code yr_aft_95, sort: egen sone=sum(one)
gen xpov_hc_55=pov_hc_55 
by wb_code, sort: replace xpov_hc_55=(xpov_hc_55[_n-1]+xpov_hc_55[_n+1])/2 /// 
                  if xpov_hc_55[_n-1]!=.&xpov_hc_55[_n+1]!=.&xpov_hc_55[_n]==.
br wb_code year xpov_hc_55 pov_hc_55
by wb_code, sort: replace xpov_hc_55 = xpov_hc_55[_n-1] if xpov_hc_55[_n-1]!= . /// 
                            & xpov_hc_55[_n] == . & sone>5
														
drop one sone							
gen one=1 if pov55!=.
replace one=0 if one==.
by wb_code yr_aft_95, sort: egen sone=sum(one)							
gen xpov55=pov55 
by wb_code, sort: replace xpov55=(xpov55[_n-1]+xpov55[_n+1])/2 /// 
                  if xpov55[_n-1]!=.&xpov55[_n+1]!=.&xpov55[_n]==.
br wb_code year xpov55 pov55
by wb_code, sort: replace xpov55 = xpov55[_n-1] if xpov55[_n-1]!= . /// 
                            & xpov55[_n] == . & sone>5										
							
xtreg xpov_pop_19 bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore p_durable wbgi_cce wbgi_gee wbgi_pse i.year ///
				 if year>1994, fe robust
est store fe41 

xtreg xpov_gap_19  bmr_dem lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore p_durable wbgi_cce wbgi_gee wbgi_pse i.year /// 
				 if year>1994, fe robust
est store fe42 

xtreg xpov_pop_32 bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable wbgi_cce wbgi_gee wbgi_pse i.year ///
				 if year>1994, fe robust
est store fe43 

xtreg xpov_gap_32  bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable wbgi_cce wbgi_gee wbgi_pse   i.year /// 
				 if year>1994, fe robust
est store fe44 

xtreg xpov_hc_55 bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable wbgi_cce wbgi_gee wbgi_pse i.year ///
				 if year>1994, fe robust
est store fe45 

xtreg xpov55 bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable wbgi_cce wbgi_gee wbgi_pse   i.year /// 
				 if year>1994, fe robust
est store fe46

outreg2 [fe41 fe42 fe43 fe44 fe45 fe46] using omit_tab1, dec(3) word see /// 
                              keep(bmr_dem) replace  /***Table A10***/

gen onepp19=1 if pov_pop_19!=.
replace onepp19=0 if onepp19==.

gen onegp19=1 if pov_gap_19!=.
replace onegp19=0 if onegp19==.

gen onepp32=1 if pov_pop_32!=.
replace onepp32=0 if onepp32==.

gen onegp32=1 if pov_gap_32!=.
replace onegp32=0 if onegp32==.

gen onepp55=1 if pov_hc_55!=.
replace onepp55=0 if onepp55==.

gen onegp55=1 if pov55!=.
replace onegp55=0 if onegp55==.

xtreg onepp19 bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable wbgi_cce wbgi_gee wbgi_pse i.year /// 
				 if year>1994, fe robust
est store om1				 				 
xtreg onegp19 bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable wbgi_cce wbgi_gee wbgi_pse i.year /// 
				 if year>1994, fe robust
est store om2
xtreg onepp32 bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable wbgi_cce wbgi_gee wbgi_pse i.year /// 
				 if year>1994, fe robust
est store om3				 
xtreg onegp19 bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable wbgi_cce wbgi_gee wbgi_pse i.year /// 
				 if year>1994, fe robust
est store om4
xtreg onepp55 bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable wbgi_cce wbgi_gee wbgi_pse i.year /// 
				 if year>1994, fe robust
est store om5				 
xtreg onegp55 bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable wbgi_cce wbgi_gee wbgi_pse i.year /// 
				 if year>1994, fe robust
est store om6

outreg2 [om*] using omit_tab, dec(3) word see keep(bmr_dem) replace /***Table A11***/

**** Table A12. Other robustness checks

xtreg pov_pop_19 bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore p_durable wbgi_cce wbgi_gee wbgi_pse i.year ///
				 if year>1994&CountryCode!="SDN"&CountryCode!="MWI"&CountryCode!="UGA"&CountryCode!="COD", fe robust
est store fe41 

xtreg pov_gap_19  bmr_dem lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore p_durable wbgi_cce wbgi_gee wbgi_pse  i.year /// 
				 if year>1994&CountryCode!="SDN"&CountryCode!="MWI"&CountryCode!="UGA"&CountryCode!="COD", fe robust
est store fe42 

xtreg pov_pop_32 bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable wbgi_cce wbgi_gee wbgi_pse al_ethnic i.year ///
				 if year>1994&CountryCode!="SDN"&CountryCode!="MWI"&CountryCode!="UGA"&CountryCode!="COD", fe robust
est store fe43 

xtreg pov_gap_32  bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable wbgi_cce wbgi_gee wbgi_pse  i.year /// 
				 if year>1994&CountryCode!="SDN"&CountryCode!="MWI"&CountryCode!="UGA"&CountryCode!="COD", fe robust
est store fe44 

xtreg pov_hc_55 bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable wbgi_cce wbgi_gee wbgi_pse  i.year ///
				 if year>1994&CountryCode!="SDN"&CountryCode!="MWI"&CountryCode!="UGA"&CountryCode!="COD", fe robust
est store fe45 

xtreg pov55 bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable wbgi_cce wbgi_gee wbgi_pse  i.year /// 
				 if year>1994&CountryCode!="SDN"&CountryCode!="MWI"&CountryCode!="UGA"&CountryCode!="COD", fe robust
est store fe46

outreg2 [fe41 fe42 fe43 fe44 fe45 fe46] using oth_rob1, dec(3) word see /// 
                   keep(bmr_dem) replace    /***Table A12 Panel A***/
			

xtreg pov_pop_19 bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable wbgi_cce wbgi_gee wbgi_pse i.year ///
				 if year>1994&region_code2!=7, fe robust
est store fe41 

xtreg pov_gap_19  bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable wbgi_cce wbgi_gee wbgi_pse i.year /// 
				 if year>1994&region_code2!=7, fe robust
est store fe42	
	
xtreg pov_pop_32 bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable wbgi_cce wbgi_gee wbgi_pse i.year ///
				 if year>1994&region_code2!=7, fe robust
est store fe43 

xtreg pov_gap_32  bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable wbgi_cce wbgi_gee wbgi_pse i.year /// 
				 if year>1994&region_code2!=7, fe robust
est store fe44

xtreg pov_hc_55 bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable wbgi_cce wbgi_gee wbgi_pse i.year ///
				 if year>1994&region_code2!=7, fe robust
est store fe45 

xtreg pov55  bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable wbgi_cce wbgi_gee wbgi_pse i.year /// 
				 if year>1994&region_code2!=7, fe robust
est store fe46

outreg2 [fe41 fe42 fe43 fe44 fe45 fe46] using oth_rob11, dec(3) word see /// 
                 keep(bmr_dem) replace /***Table A12 Panel B***/	 
				 
xtset wb_code year

xtreg l(0/2).xpov_pop_19 bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable  i.year ///
				 if year>1994, fe robust
est store fe41 

xtreg l(0/2).xpov_gap_19  bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable   i.year /// 
				 if year>1994, fe robust
est store fe42 

xtreg l(0/2).xpov_pop_32 bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable i.year ///
				 if year>1994, fe robust
est store fe43 

xtreg l(0/2).xpov_gap_32  bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable i.year /// 
				 if year>1994, fe robust
est store fe44 

xtreg l(0/2).xpov_hc_55 bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable i.year ///
				 if year>1994, fe robust
est store fe45 

xtreg l(0/2).xpov55 bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable i.year /// 
				 if year>1994, fe robust
est store fe46

outreg2 [fe41 fe42 fe43 fe44 fe45 fe46] using oth_rob2, dec(3) word see /// 
                 keep(bmr_dem) replace  /***Table A12 Panel C***/
 
**** Table 3.The Mediation Effect of Political Rights and Freedom of Speech 

xtreg pov_pop_19 n_pr lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore p_durable  i.year ///
				 if year>1994, fe robust
est store fe41 

xtreg pov_gap_19  n_pr lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore p_durable  i.year /// 
				 if year>1994, fe robust
est store fe42 

xtreg pov_pop_32 n_pr lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable  i.year ///
				 if year>1994, fe robust
est store fe43 

xtreg pov_gap_32  n_pr lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable  i.year /// 
				 if year>1994, fe robust
est store fe44 

outreg2 [fe41 fe42 fe43 fe44 ] using mech1, dec(3) word see keep(n_pr) replace
                                     /***Table 3 Panel A***/ 

xtreg n_pr bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore p_durable  i.year ///
				 if year>1994, fe robust
est store n_pr
gen free_sp=ciri_speech

xtreg free_sp bmr_dem lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore p_durable i.year ///
				 if year>1994, fe robust
est store free_sp				 
outreg2 [n_pr free_sp] using tab_r2_1, word dec(3) see keep(bmr_dem)

xtreg pov_pop_19 free_sp lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore p_durable i.year ///
				 if year>1994, fe robust
est store fe41 

xtreg pov_gap_19 free_sp lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore p_durable i.year /// 
				 if year>1994, fe robust
est store fe42 

xtreg pov_pop_32 free_sp lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable  i.year ///
				 if year>1994, fe robust
est store fe43 

xtreg pov_gap_32 free_sp lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore  p_durable   i.year /// 
				 if year>1994, fe robust
est store fe44 

outreg2 [fe41 fe42 fe43 fe44] using mech2, dec(3) word see keep(free_sp) replace 
                                               /***Table 3 Panel B***/

**** Table 4. The Mediation Effect of Middle Size and Governmental Quality 
**** Middle class: source: http://iresearch.worldbank.org/PovcalNet/povOnDemand.aspx

xtset wb_code year

gen vul_hc=pov_hc_10-pov_pop_32
xtreg vul_hc bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore p_durable i.year ///
				 if year>1994, fe robust
est store fe41
				 
gen vul_hc2=pov_gap_10-pov_gap_32				 
xtreg vul_hc2 bmr_dem lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl p_durable ///
                 hf_efiscore p_durable i.year ///
				 if year>1994, fe robust
est store fe42


xtreg wbgi_gee bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore p_durable  i.year ///
				 if year>1994, fe robust
est store fe43
				 				 
xtreg wbgi_pse bmr_dem lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl p_durable ///
                 hf_efiscore p_durable i.year ///
				 if year>1994, fe robust
est store fe44

xtreg wbgi_cce bmr_dem lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore p_durable i.year ///
				 if year>1994, fe robust
est store fe45

outreg2 [fe41 fe42 fe43 fe44 fe45] using mech_3, word dec(3) see keep(bmr_dem) replace
                                                               /***Table 4***/
			 
****Table 5. The Lagged Effects of Democracy on Poverty Reduction
xtset wb_code year
gen bmr_dem_l2=l2.bmr_dem-l3.bmr_dem
sum bmr_dem_l2
replace bmr_dem_l2=0 if bmr_dem_l2<0

by wb_code, sort:egen no_dem=sum(bmr_dem_l2)
replace bmr_dem_l2=0 if (cname=="Albania"&year==1999)|(cname=="Bangladesh"&year==2011)|(cname=="Niger"&year==2001)| ///
                        (cname=="Niger"&year==2013)|(cname=="Nepal"&year==2010)|(cname=="Thailand"&year==2013)
drop no_dem
by wb_code, sort:egen no_dem=sum(bmr_dem_l2)
drop no_dem

gen bmr_dem_l3=l3.bmr_dem-l4.bmr_dem
sum bmr_dem_l3
replace bmr_dem_l3=0 if bmr_dem_l3<0

by wb_code, sort:egen no_dem=sum(bmr_dem_l3)
replace bmr_dem_l3=0 if (cname=="Albania"&year==2000)|(cname=="Bangladesh"&year==2012)|(cname=="Niger"&year==2002)| ///
                        (cname=="Niger"&year==2014)|(cname=="Nepal"&year==2011)|(cname=="Thailand"&year==2014)
drop no_dem
by wb_code, sort:egen no_dem=sum(bmr_dem_l3)
drop no_dem

gen bmr_dem_l4=l4.bmr_dem-l5.bmr_dem
sum bmr_dem_l4
replace bmr_dem_l4=0 if bmr_dem_l4<0

gen l2_bmr_dem=l2.bmr_dem
gen l3_bmr_dem=l3.bmr_dem
gen l4_bmr_dem=l4.bmr_dem
gen l5_bmr_dem=l5.bmr_dem
replace l5_bmr_dem=0 if l5_bmr_dem==.&bmr_dem!=.


xtreg pov_pop_19 bmr_dem_l0 bmr_dem_l1 bmr_dem_l2 l3_bmr_dem lwb_gdppc11 ///
                 hc lpop_dnst wdi_trade imf_infl  hf_efiscore pol_sys3 p_durable ///
				 wbgi_cce wbgi_gee wbgi_pse i.year if year>1994, fe robust
est store fe01

xtreg pov_gap_19 bmr_dem_l0 bmr_dem_l1 bmr_dem_l2 l3_bmr_dem lwb_gdppc11 ///
                 hc lpop_dnst wdi_trade imf_infl  hf_efiscore pol_sys3 p_durable ///
				 wbgi_cce wbgi_gee wbgi_pse i.year if year>1994, fe robust
est store fe02

xtreg pov_pop_32 bmr_dem_l0 bmr_dem_l1 bmr_dem_l2 l3_bmr_dem ///
                 polity2 lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl hf_efiscore ///
                 p_durable wbgi_cce wbgi_gee wbgi_pse i.year if year>1994, fe robust
est store fe11


xtreg pov_gap_32 bmr_dem_l0 bmr_dem_l1 bmr_dem_l2  l3_bmr_dem ///
                 polity2 lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl hf_efiscore ///
                 p_durable wbgi_cce wbgi_gee wbgi_pse i.year if year>1994, fe robust
est store fe12


xtreg pov_hc_55  bmr_dem_l0 bmr_dem_l1 bmr_dem_l2 l3_bmr_dem ///
                 polity2 lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl hf_efiscore ///
                 p_durable wbgi_cce wbgi_gee wbgi_pse i.year if year>1994, fe robust
est store fe21


xtreg pov55      bmr_dem_l0 bmr_dem_l1 bmr_dem_l2 l3_bmr_dem ///
                 polity2 lwb_gdppc11 hc lpop_dnst wdi_trade imf_infl hf_efiscore ///
                 p_durable wbgi_cce wbgi_gee wbgi_pse i.year if year>1994, fe robust
est store fe22

outreg2 [fe01 fe02 fe11 fe12 fe21 fe22] using result, dec(3) word see replace /// 
                keep(bmr* l3*) nocons          /****Table 5***/



***** Table A14. Heterogeneity effects by democratization type

**** Generate full democratization dummy
drop suc_dem par_dem bl_rv_dem
    gen suc_dem=1 if iso2_code==16 &year>1983
	replace suc_dem=1 if iso2_code==30 &year>1991
	replace suc_dem=1 if iso2_code==33 &year>1982
	replace suc_dem=1 if iso2_code==34 &year>1985
	replace suc_dem=1 if iso2_code==27 &year>1991
	replace suc_dem=1 if iso2_code==52 &year>1991
	replace suc_dem=1 if iso2_code==46 &year>1990
	replace suc_dem=1 if iso2_code==90 &year>2000
	replace suc_dem=1 if iso2_code==55 &year>1993
	replace suc_dem=1 if iso2_code==60 &year>1978
	replace suc_dem=1 if iso2_code==62 &year>1979
	replace suc_dem=1 if iso2_code==198 &year>1994
	replace suc_dem=1 if iso2_code==63 &year>1992
	replace suc_dem=1 if iso2_code==78 &year>1996
	replace suc_dem=1 if iso2_code==83 &year>1975
	replace suc_dem=1 if iso2_code==76 &year>1984
	replace suc_dem=1 if iso2_code==87 &year>1992
	replace suc_dem=1 if iso2_code==89 &year>1982
	replace suc_dem=1 if iso2_code==92 &year>1990
	replace suc_dem=1 if iso2_code==113 &year>1988
	replace suc_dem=1 if iso2_code==127 &year>1993
	replace suc_dem=1 if iso2_code==125 &year>1993
	replace suc_dem=1 if iso2_code==138 &year>1992
	replace suc_dem=1 if iso2_code==148 &year>1997
	replace suc_dem=1 if iso2_code==140 &year>1993
	replace suc_dem=1 if iso2_code==162 &year>1994
	replace suc_dem=1 if iso2_code==163 &year>1980
	replace suc_dem=1 if iso2_code==166 &year>1987
	replace suc_dem=1 if iso2_code==168 &year>1990
	replace suc_dem=1 if iso2_code==171 &year>1976
	replace suc_dem=1 if iso2_code==175 &year>1990
	replace suc_dem=1 if iso2_code==197 &year>1991
	replace suc_dem=1 if iso2_code==193 &year>2000
	replace suc_dem=1 if iso2_code==190 &year>1993
	replace suc_dem=1 if iso2_code==189 &year>1992
	replace suc_dem=1 if iso2_code==242 &year>1994
	replace suc_dem=1 if iso2_code==66 &year>1978
	replace suc_dem=1 if iso2_code==205 &year>1992
	replace suc_dem=1 if iso2_code==218 &year>1985
	replace suc_dem=0 if suc_dem!=1
	lab var suc_dem "Countries successfully democratized,1, otherwise, 0"
	
**** Generate partial democratization dummy
    gen par_dem=1 if iso2_code==13 &year>1992
	replace par_dem=1 if iso2_code==14 &year>1998
	replace par_dem=1 if iso2_code==24 &year>1991
	replace par_dem=1 if iso2_code==57 &year>1999
	replace par_dem=1 if iso2_code==67 &year>1995
	replace par_dem=1 if iso2_code==77 &year>1995
	replace par_dem=1 if iso2_code==84 &year>1996
	replace par_dem=1 if iso2_code==93 &year>1999
	replace par_dem=1 if iso2_code==124 &year>1993
	replace par_dem=1 if iso2_code==137 &year>1991
	replace par_dem=1 if iso2_code==135 &year>1993
	replace par_dem=1 if iso2_code==147 &year>1994
	replace par_dem=1 if iso2_code==132 &year>1994
	replace par_dem=1 if iso2_code==150 &year>1994
	replace par_dem=1 if iso2_code==155 &year>1990
	replace par_dem=1 if iso2_code==154 &year>1999
	replace par_dem=1 if iso2_code==173 &year>1993
	replace par_dem=1 if iso2_code==177 &year>1993
	replace par_dem=1 if iso2_code==176 &year>2000
	replace par_dem=1 if iso2_code==195 &year>1991
	replace par_dem=1 if iso2_code==214 &year>1995
	replace par_dem=1 if iso2_code==211 &year>1983
	replace par_dem=1 if iso2_code==215 &year>1994
	replace par_dem=1 if iso2_code==246 &year>1991
	replace par_dem=0 if par_dem!=1
	lab var par_dem "Partially democratized countries,1; otherwise, 0"
	
****generate borderline and reversal democratization dummy
    gen bl_rv_dem=1 if iso2_code==42 &year>1993
	replace bl_rv_dem=1 if iso2_code==110 &year>1990
	replace bl_rv_dem=1 if iso2_code==99 &year>1997
	replace bl_rv_dem=1 if iso2_code==158 &year>1991
	replace bl_rv_dem=1 if iso2_code==153 &year>1999
	replace bl_rv_dem=1 if iso2_code==167 &year>1988
	***borderline democratization
	replace bl_rv_dem=1 if iso2_code==80 &year>1994
	replace bl_rv_dem=1 if iso2_code==119 &year>1975
	replace bl_rv_dem=1 if iso2_code==248 &year>1987
	***reversal in autocracy
	replace bl_rv_dem=0 if bl_rv_dem!=1
	lab var bl_rv_dem "countries with borderline democratization and reversal in autocracy"
	***Source: Papaioannou and Siourounis (2007), table 1.

xtreg pov_pop_19 suc_dem par_dem  lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore p_durable wbgi_cce wbgi_gee wbgi_pse i.year /// 
				 if year>1994, fe robust
est store fe01

xtreg pov_gap_19 suc_dem par_dem  lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore p_durable wbgi_cce wbgi_gee wbgi_pse i.year /// 
				 if year>1994, fe robust
est store fe02

xtreg pov_pop_32 suc_dem par_dem  lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore p_durable wbgi_cce wbgi_gee wbgi_pse i.year ///
				 if year>1994, fe robust
est store fe11

xtreg pov_gap_32 suc_dem par_dem  lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore p_durable wbgi_cce wbgi_gee wbgi_pse i.year ///
				 if year>1994, fe robust
est store fe12

xtreg pov_hc_55 suc_dem par_dem  lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore p_durable wbgi_cce wbgi_gee wbgi_pse i.year /// 
				 if year>1994, fe robust
est store fe21

xtreg pov55 suc_dem par_dem  lwb_gdppc11  hc lpop_dnst wdi_trade imf_infl ///
                 hf_efiscore p_durable wbgi_cce wbgi_gee wbgi_pse i.year ///
				 if year>1994, fe robust
est store fe22

outreg2 [fe01 fe02 fe11 fe12 fe21 fe22] using result, dec(3) word see replace ///
                 keep(suc_dem par_dem) nocons   /****Table A14***/

clear

*****************The end of do file*********************************************
